package com.songhaozhi.mayday.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
@ConfigurationProperties(prefix = "ali")
@Data
public class AliLoginConf {

    private String URL;
    private String APP_ID;
    private String APP_PRIVATE_KEY;
    private String FORMAT;
    private String CHARSET;
    private String ALIPAY_PUBLIC_KEY;
    private String SIGN_TYPE;


    @Bean
    public AlipayClient getAlipayClient() throws Exception {
        AlipayClient alipayClient = new DefaultAlipayClient(URL, APP_ID, APP_PRIVATE_KEY, FORMAT, CHARSET, ALIPAY_PUBLIC_KEY, SIGN_TYPE);
        log.info("注入支付宝客户端成功");
        return alipayClient;
    }
}
